package net.csdn.business.kanban.api.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;

import net.csdn.business.kanban.api.facade.KanbanFieldFacade;
import net.csdn.business.kanban.common.domain.request.KanbanFieldParam;
import net.csdn.business.kanban.common.domain.request.KanbanFieldUpdateParam;
import net.csdn.business.kanban.common.domain.resp.KanbanFieldResp;
import net.csdn.business.kanban.feign.annotation.Inner;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * @ClassName KanbanDetailController
 * @Description TODO
 * @Author liuzhisheng
 * @Date 2023/9/14
 **/
@Inner
@RestController
@RequestMapping("/api/v1/kanban/field")
@RequiredArgsConstructor
@Api(tags = "自定义字段")
public class KanbanFieldController {
    private final KanbanFieldFacade kanbanFieldFacade;

    @PostMapping
    @ApiOperation(value = "自定义字段新增")
    public boolean addKanbanField(@Validated @RequestBody KanbanFieldParam kanbanFieldParam) {
        return kanbanFieldFacade.addKanbanField(kanbanFieldParam);
    }

    @PutMapping
    @ApiOperation(value = "自定义字段编辑")
    public boolean updateKanbanField(@Validated @RequestBody KanbanFieldUpdateParam kanbanFieldUpdateParam) {
        return kanbanFieldFacade.updateKanbanField(kanbanFieldUpdateParam);
    }

    @DeleteMapping("/{id}")
    @ApiOperation(value = "自定义字段删除")
    public boolean deleteKanbanField(@PathVariable("id") Long id,@RequestParam("kanbanId") String kanbanId) {
        return kanbanFieldFacade.deleteKanbanField(id,kanbanId);
    }

    @GetMapping("/fieldSetting/{kanbanId}")
    @ApiOperation(value = "自定义字段列表(包括扩展属性)")
    public List<KanbanFieldResp> fieldSettings(@PathVariable("kanbanId") String kanbanId) {
        return kanbanFieldFacade.fieldSettings(kanbanId);
    }

    @GetMapping("/fieldList/{kanbanId}")
    @ApiOperation(value = "自定义字段列表(简单)")
    public List<KanbanFieldResp> fieldList(@PathVariable("kanbanId") String kanbanId) {
        return kanbanFieldFacade.fieldList(kanbanId);
    }

    @GetMapping("/info/{id}")
    @ApiOperation(value = "获取字段的扩展详情信息")
    public KanbanFieldResp fieldInfo(@PathVariable("id") Long id, @RequestParam("kanbanId") String kanbanId) {
        return kanbanFieldFacade.fieldInfo(id,kanbanId);
    }
}
